



private ["_basePlayer","_pos","_C130","_group","_USMCgroup","_WP1","_c130array","_dir","_wp2","_nearestCity","_statements","_statement1","_statement2"];
while {true} do {
    sleep (round (random 200));   
    {
        //send in USMC via C130
        _basePlayer=_x;
        _pos = [(position _basePlayer select 0) + 10000,position _baseplayer select 1, 0]; 
        _c130array = [_pos, 90, "c130J", WEST] call bis_fnc_spawnvehicle;
		_c130 = _c130array select 0;
		_c130 setpos [position _c130 select 0, position _c130 select 1, (position _c130 select 2) + 150];
		_dir = [_baseplayer, _c130] call BIS_fnc_relativeDirTo;
		_c130 setDir _dir;
		_group = _C130array select 2;
		
		 //tell the plane where to go:
		_WP1 = _group addWaypoint [(position _basePlayer), random 100,0];
        _WP1 setWaypointType "move";
        _wp2 = _group addWaypoint [[-5000,-5000],0,1];
        _WP2 setWaypointType "move";
        
        _group setCurrentWaypoint [_group, 0];
        _USMCgroup = [[0,0] , West, 12 ] call BIS_fnc_spawnGroup;
       
        { 
            _x moveInCargo _C130; 
        } forEach units _USMCgroup;
        
       // wait until plane is at position 
       
        _pos = getWPPos [_group, 0];
        waitUntil{ (_pos distance (position _c130)) < 150 };
		
        sleep random 3; 
        
       // eject
        
        {
         _x action ["eject", vehicle _x];
        } forEach units _USMCgroup;
        
        //find nearest town and send soldiers there
        _nearestCity = nearestLocation [position _basePlayer, "cityCenter"];
        _WP1 = _USMCgroup addWaypoint [(position _nearestCity),0,0];
        _WP1 setWaypointType "move";
        _statements = waypointStatements [_USMCgroup, 0];
        _statement1 = _statements select 0;
        _statement2 = "nul=[group this, position this, 100] call BIS_fnc_taskPatrol;";
        _WP1 setWaypointStatements [_statement1,_statement2];
        _USMCgroup setCurrentWaypoint [_USMCgroup, 0];
        
        
        
    } forEach playableUnits;
    
};